package org.hbgl.geoentity.admin.web.admin;

import com.alibaba.fastjson.JSON;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.hbgl.geoentity.admin.annotation.ExamineLog;
import org.hbgl.geoentity.admin.annotation.OperationLog;
import org.hbgl.geoentity.admin.annotation.RequiresPermissionsDesc;
import org.hbgl.geoentity.admin.aspect.OperationType;
import org.hbgl.geoentity.admin.shiro.UserType;
import org.hbgl.geoentity.admin.web.BaseController;
import org.hbgl.geoentity.core.util.*;
import org.hbgl.geoentity.core.util.bcrypt.BCryptPasswordEncoder;
import org.hbgl.geoentity.db.domain.*;
import org.hbgl.geoentity.db.util.EnumFile;
import org.hbgl.geoentity.db.vo.NodeApplyVo;
import org.hbgl.geoentity.db.vo.NodeVo;
import org.hbgl.geoentity.db.vo.UnitVo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.io.File;
import java.io.FileWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.format.DateTimeFormatter;
import java.util.*;

import static org.hbgl.geoentity.admin.util.ResponseCode.*;

/**
 * 代码功能：
 * 开发日期：2022/4/22
 * 作者：蒋海仑
 * 联系方式：
 * 版本更迭说明：
 * 版权信息：河北广联信息技术有限公司
 */
@RestController
@RequestMapping("/admin/node")
@Validated
// @RequiresAuthentication
public class AdminNodeController extends BaseController {

    @Value("${gyhlw.companyinfo.reporting}")
    private boolean GYHLW_COMPANYINFO_REPORTING;

    //region 业务管理--节点管理

    @RequiresPermissions("admin:node:list")
    @RequiresPermissionsDesc(menu = {"业务管理", "节点管理"}, button = "查询")
    @GetMapping("/list")
    public Object list(
            // @RequestParam(defaultValue = "") String area,
            @RequestParam(defaultValue = "-1") Integer nodeType,
            @RequestParam(defaultValue = "-2") Integer examState,
            @RequestParam(defaultValue = "") String keywords,
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer limit) {
        // List<NodeVo> userList = nodeService.selectNodeList(area, keywords, page, limit);
        List<NodeVo> userList = nodeService.selectNodeListNew(nodeType, examState, keywords, page, limit);
        return ResponseUtil.okList(userList);
    }

    /**
     * 检查节点编码是否可用
     *
     * @param body { nodeIdcode : 节点编码 }
     */
    @PostMapping("/checkNodeIdcode")
    public Object checkNodeIdcode(@RequestBody String body) {
        String nodeIdcode = JacksonUtil.parseString(body, "nodeIdcode");
        if (!ObjectUtils.allNotNull(nodeIdcode)) {
            return ResponseUtil.badArgument();
        }
        if (StringUtils.isBlank(nodeIdcode)) {
            return ResponseUtil.fail(402, "节点编码不能为空");
        }

//        if (nodeService.findByNodeIdcode(nodeIdcode).size() > 0) {
//            return ResponseUtil.fail(AUTH_NODEIDCODE_EXIST, "节点编码已经存在");
//        }

        return ResponseUtil.ok();
    }

    /**
     * 检查单位名称是否可用
     *
     * @param body { unitName : 单位名称 }
     */
    @PostMapping("/checkUnitname")
    public Object checkUnitname(@RequestBody String body) {
        String unitName = JacksonUtil.parseString(body, "unitName");
        if (!ObjectUtils.allNotNull(unitName)) {
            return ResponseUtil.badArgument();
        }
        if (StringUtils.isBlank(unitName)) {
            return ResponseUtil.fail(402, "单位名称不能为空");
        }

        if (unitService.findByUnitName(unitName).size() > 0) {
            return ResponseUtil.fail(AUTH_UNITNAME_EXIST, "单位名称已经存在");
        }

        return ResponseUtil.ok();
    }

    @PostMapping("/topNode")
    public Object topNode() {
        GeNode node = nodeService.findByParentId(0);
        if (node == null) {
            return ResponseUtil.badArgument();
        }
        return ResponseUtil.ok(node.getNodeIdcode() + ".");
    }

    /**
     * 新建节点
     * @param nodeVo
     * @return
     */
    // @RequiresPermissions("admin:node:create")
    // @RequiresPermissionsDesc(menu = {"业务管理", "节点管理"}, button = "新建")
    @OperationLog(detail = "新建节点", operationType = OperationType.INSERT, userType = UserType.ADMIN)
    @PostMapping("/create")
    public Object create(@RequestBody NodeVo nodeVo) {
        if (!ObjectUtils.allNotNull(nodeVo.getNodeId(), nodeVo.getUnitId(),
                nodeVo.getNodeIdcode(), nodeVo.getNodeType()
                , nodeVo.getContractAgreement())
        ) {
            return ResponseUtil.badArgument();
        }
        if (StringUtils.isBlank(nodeVo.getNodeIdcode())) {
            return ResponseUtil.badArgumentValue();
        }
//        if (!RegexUtil.isNodeIdcode(nodeVo.getNodeIdcode())) {
//            return ResponseUtil.fail(ENTITYID_INVALID, "节点编码不符合规定");
//        }
        NodeApplyVo nodeApplyById = nodeService.findNodeApplyById(nodeVo.getNodeId());
        List<GeNode> nodeByNodeName = nodeService.findNodeByNodeName(nodeApplyById.getNodeName());
        if(nodeByNodeName != null && nodeByNodeName.size()>0) {
            return ResponseUtil.fail(AUTH_NODEIDCODE_EXIST, "节点名称已经存在");
        }
//        if (nodeService.findByNodeIdcode(nodeVo.getNodeIdcode()).size() > 0) {
//            return ResponseUtil.fail(AUTH_NODEIDCODE_EXIST, "节点编码已经存在");
//        }
        // if (StringUtils.isBlank(nodeVo.getUnitName())) {
        //     return ResponseUtil.badArgumentValue();
        // }
        // if (unitService.findByUnitName(nodeVo.getUnitName()).size() > 0) {
        //     return ResponseUtil.fail(AUTH_UNITNAME_EXIST, "单位名称已经存在");
        // }

        nodeService.add(nodeVo);

        return ResponseUtil.ok();
    }

    //通过单位id获取单位的节点申请表列表
    @GetMapping(value = "findNodeApplyByUnitId")
    public Object findNodeApplyByUnitId(Integer unitId) {
        List<GeNodeApply> nodeApplyList = nodeService.findNodeApplyByUnitId(unitId);
        return ResponseUtil.ok(nodeApplyList);
    }

    //通过单位id获取单位的添加节点下拉框列表
    @GetMapping(value = "findNodeBoxByUnitId")
    public Object findNodeBoxByUnitId(Integer unitId) {
        List<GeNodeApply> nodeApplyList = nodeService.findNodeBoxByUnitId(unitId);
        return ResponseUtil.ok(nodeApplyList);
    }

    /**
     * 编辑节点
     * @param nodeVo
     * @return
     */
    @RequiresPermissions("admin:node:update")
    @RequiresPermissionsDesc(menu = {"业务管理", "节点管理"}, button = "编辑")
    @OperationLog(detail = "更新节点信息", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @PostMapping("/update")
    public Object update(@RequestBody NodeVo nodeVo) {
        if (!ObjectUtils.allNotNull(nodeVo.getNodeId(), nodeVo.getUnitId(), nodeVo.getNodeType())
        ) {
            return ResponseUtil.badArgument();
        }
        // if (StringUtils.isBlank(nodeVo.getNodeIdcode())) {
        //     return ResponseUtil.badArgumentValue();
        // }
        if (StringUtils.isBlank(nodeVo.getContractAgreement())) {
            return ResponseUtil.badArgumentValue();
        }
        // if (!RegexUtil.isNodeIdcode(nodeVo.getNodeIdcode())) {
        //     return ResponseUtil.fail(ENTITYID_INVALID, "节点编码不符合规定");
        // }
        //判断节点是否可以编辑
        List<NodeVo> authList = nodeService.findAuthByNodeId(nodeVo.getNodeId());
        if(authList != null && authList.size()>0) {
            return ResponseUtil.fail(ENTITYID_INVALID, "该节点已进行接入操作，不允许修改");
        }
        NodeVo nodeLatest = nodeService.findById(nodeVo.getNodeId());
        if (nodeLatest == null) {
            return ResponseUtil.badArgument();
        }
        List<GeNode> byNodeIdcode = nodeService.findByNodeIdcode(nodeLatest.getNodeId(), nodeVo.getNodeIdcode());
        if (byNodeIdcode !=null && byNodeIdcode.size() > 0) {
            return ResponseUtil.fail(AUTH_NODEIDCODE_EXIST, "节点编码已经存在");
        }
        // if (unitService.findByUnitName(nodeLatest.getUnitId(), nodeVo.getUnitName()).size() > 0) {
        //     return ResponseUtil.fail(AUTH_UNITNAME_EXIST, "单位名称已经存在");
        // }

        nodeVo.setNodeId(nodeLatest.getNodeId());
        nodeVo.setUnitId(nodeLatest.getUnitId());
        // nodeVo.setExamState(EnumFile.ExamineState.Wait);
        // nodeVo.setNodeIdcode(null);

        if (nodeService.updateById(nodeVo) == 0) {
            return ResponseUtil.updatedDataFailed();
        }

        return ResponseUtil.ok();
    }

    /**
     * 删除节点
     * @param body
     * @return
     */
    @RequiresPermissions("admin:node:delete")
    @RequiresPermissionsDesc(menu = {"业务管理", "节点管理"}, button = "删除")
    @OperationLog(detail = "删除节点", operationType = OperationType.DELETE, userType = UserType.ADMIN)
    @PostMapping("/delete")
    public Object delete(@RequestBody String body) {
        Integer id = JacksonUtil.parseInteger(body, "id");
        if (id == null) {
            return ResponseUtil.badArgument();
        }

        NodeVo nodeLatest = nodeService.findById(id);
        if (nodeLatest == null) {
            return ResponseUtil.badArgument();
        }

        if (nodeService.deleteByIdLogical(id) == 0) {
            return ResponseUtil.deletedDataFailed();
        }

        return ResponseUtil.ok();
    }

    // @RequiresPermissions("admin:node:download")
    // @RequiresPermissionsDesc(menu = {"节点管理", "节点管理"}, button = "下载授权")
    // @OperationLog(detail = "下载授权", operationType = OperationType.SELECT, userType = UserType.ADMIN)
    @GetMapping("/download")
    public Object download(Integer id) throws Exception {
        if (id == null) {
            return null;
        }
        NodeVo nodeLatest = nodeService.findById(id);
        if (nodeLatest == null) {
            return null;
        }

        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        Map<String, Object> data = new LinkedHashMap<>();
        data.put("节点性质", "地理实体MA标识二级节点");
        data.put("节点ID", nodeLatest.getNodeId());
        data.put("节点编码", nodeLatest.getNodeIdcode());
        data.put("节点区域", nodeLatest.getAreaName());
        data.put("节点区域编码", nodeLatest.getAreaCode());
        data.put("单位名称", nodeLatest.getUnitName());
        data.put("创建时间", dtf.format(nodeLatest.getAddTime()));
        data.put("授权KEY", nodeLatest.getAppKey());
        data.put("IP类型", nodeLatest.getIpType());
        data.put("IP地址", nodeLatest.getIp());
        data.put("TCP端口", nodeLatest.getTcpPort());
        data.put("UDP端口", nodeLatest.getUdpPort());
        data.put("HTTP端口", nodeLatest.getHttpPort());
        String content = JSON.toJSONString(data);
        String password = "4JaCqrqkc2K9pFcyohcbMi53QLbHdQEuJ01sNbeVG8PW8QeROeYFd1etWXspTj0Q";
        content = AESUtil.encrypt(content, password);
        // System.out.println(AESUtil.decrypt(content, password));

        //region 生成加密后的码包
        Path path = Paths.get("license");
        Files.createDirectories(path);
        String IDCODEURL = path.toFile().getPath();
        String f_name = nodeLatest.getProvinceName();
        if(StringUtils.isNotBlank(nodeLatest.getAreaName())) {
            f_name = nodeLatest.getAreaName();
        }else {
            if (StringUtils.isNotBlank(nodeLatest.getCityName())) {
                f_name = nodeLatest.getCityName();
            }
        }
        String fileName = "MA_Secondary_Node_" + f_name + ".config";
        FileWriter writer = new FileWriter(IDCODEURL + File.separator + fileName);

        writer.write(content);
        writer.flush();
        writer.close();
        //endregion

        //保存的文件路径
        File outfile = new File(IDCODEURL + File.separator + fileName);
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
        headers.setContentDispositionFormData("attachment", new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1));
        return new ResponseEntity<>(FileUtils.readFileToByteArray(outfile), headers, HttpStatus.OK);
    }


    /**
     * 根据节点ID获取节点信息
     *
     * @param id 节点ID
     */
    @RequiresPermissions("admin:node:detail")
    @RequiresPermissionsDesc(menu = {"业务管理", "节点管理"}, button = "详情")
    @GetMapping("/detail")
    public Object detail(@NotNull Integer id) {
        NodeVo nodeLatest = nodeService.findById(id);
        if (nodeLatest == null) {
            return ResponseUtil.badArgumentValue();
        }
        return ResponseUtil.ok(nodeLatest);
    }

    //首页注册服务机构列表
    @GetMapping(value = "unitList")
    public Object nodeList() {
        List<NodeVo> unitList = nodeService.selectNodeForShow();
        return ResponseUtil.okList(unitList);
    }

    /**
     * 单位下拉框列表
     * @return
     */
    @GetMapping(value = "unitAllList")
    public Object unitAllList() {
        List<GeUnit> unitList = nodeService.selectUnitListAll();
        return ResponseUtil.ok(unitList);
    }

    /**
     * 节点管理启用/禁用
     *
     */
    @RequiresPermissions("admin:assess:nodestate")
    @RequiresPermissionsDesc(menu = {"业务管理", "节点管理"}, button = "启用/禁用")
    @OperationLog(detail = "启用/禁用节点", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @PostMapping("/nodeState")
    public Object nodeState(@RequestBody String body) {
        Integer id = JacksonUtil.parseInteger(body, "id");
        Integer state = JacksonUtil.parseInteger(body, "state");
        if (!ObjectUtils.allNotNull(
                id, state
        )) {
            return ResponseUtil.badArgument();
        }
        if (state != EnumFile.CommonState.Normal && state != EnumFile.CommonState.Disable) {
            return ResponseUtil.badArgumentValue();
        }

        if (nodeService.updateStateById(id, state) == 0) {
            return ResponseUtil.updatedDataFailed();
        }

        return ResponseUtil.ok();
    }

    //endregion

    //region 业务管理--接入管理
    /**
     * 接入管理列表
     *
     */
    @RequiresPermissions("admin:assess:list")
    @RequiresPermissionsDesc(menu = {"业务管理", "接入管理"}, button = "查询")
    @GetMapping("/assessList")
    public Object assessList(@RequestParam(defaultValue = "") String area,
                             @RequestParam(defaultValue = "-2") Integer examState,
                             @RequestParam(defaultValue = "") String keywords,
                             @RequestParam(defaultValue = "1") Integer page,
                             @RequestParam(defaultValue = "10") Integer limit) {
        List<NodeVo> accessList = unitService.selectAssessList(area, examState, keywords, page, limit);
        return ResponseUtil.okList(accessList);
    }

    /**
     * 接入管理启用/禁用
     *
     */
    @RequiresPermissions("admin:assess:authstate")
    @RequiresPermissionsDesc(menu = {"业务管理", "接入管理"}, button = "启用/禁用")
    @OperationLog(detail = "启用/禁用单位接入", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @PostMapping("/assessState")
    public Object assessState(@RequestBody String body) {
        Integer id = JacksonUtil.parseInteger(body, "id");
        Integer state = JacksonUtil.parseInteger(body, "state");
        if (!ObjectUtils.allNotNull(
                id, state
        )) {
            return ResponseUtil.badArgument();
        }
        if (state != EnumFile.CommonState.Normal && state != EnumFile.CommonState.Disable) {
            return ResponseUtil.badArgumentValue();
        }

        GeUser userCurrent = getCurrentAdminUser();
        if (userCurrent.getUnitId().equals(id)) {
            return ResponseUtil.fail(USER_DELETE_NOT_ALLOWED, "不能启用/禁用自己单位接入");
        }

        if (unitService.updateAssessStateById(id, state) == 0) {
            return ResponseUtil.updatedDataFailed();
        }
        NodeVo auth = nodeService.findAuthById(id);
        Map<String, String> params = new HashMap<>();
        params.put("state", state + "");
        HttpUtil.sendPost("http://" + auth.getIp() + ":" + auth.getHttpPort() + "/api/public/assessState", params);

        return ResponseUtil.ok();
    }

    /**
     * 当前账号信息授权信息
     *
     */
    @RequiresPermissions("admin:auth:accessinfo")
    @RequiresPermissionsDesc(menu = {"业务管理", "接入管理"}, button = "查看")
    @OperationLog(detail = "查看接入管理信息详情", operationType = OperationType.SELECT, userType = UserType.ADMIN)
    @PostMapping("/accessInfo")
    public Object accessInfo(@RequestBody String body) {
        Integer id = JacksonUtil.parseInteger(body, "id");
        NodeVo nodeVo = unitService.findAssessByAuthId(id);
        if (nodeVo == null) {
            return ResponseUtil.fail();
        }
        return ResponseUtil.ok(nodeVo);
    }

    //endregion

    //region 业务管理--企业管理

    @RequiresPermissions("admin:unit:unitmanagelist")
    @RequiresPermissionsDesc(menu = {"业务管理", "单位管理"}, button = "查询")
    @OperationLog(detail = "单位管理列表", operationType = OperationType.SELECT, userType = UserType.ADMIN)
    @GetMapping("/unitManageList")
    public Object unitManageList( @RequestParam(defaultValue = "") String area,
                                  @RequestParam(defaultValue = "-2") Integer examState,
                                  @RequestParam(defaultValue = "") String keywords,
                                  @RequestParam(defaultValue = "1") Integer page,
                                  @RequestParam(defaultValue = "10") Integer limit) {

        List<UnitVo> unitVos = unitService.selectUnitList(area, examState, keywords, page, limit);
        return ResponseUtil.okList(unitVos);
    }

    /**
     * 单位详情
     *
     * @param id 节点ID
     */
    @RequiresPermissions("admin:unit:unitdetail")
    @RequiresPermissionsDesc(menu = {"业务管理", "单位管理"}, button = "详情")
    @OperationLog(detail = "单位详情", operationType = OperationType.SELECT, userType = UserType.ADMIN)
    @GetMapping("/unitDetail")
    public Object unitDetail(@NotNull Integer id) {
        UnitVo unitVo = unitService.selectUnitById(id);
        if (unitVo == null) {
            return ResponseUtil.badArgumentValue();
        }
        return ResponseUtil.ok(unitVo);
    }

    /**
     * 单位启用/禁用
     *
     * @param id 节点ID
     */
    @RequiresPermissions("admin:unit:unitestate")
    @RequiresPermissionsDesc(menu = {"业务管理", "单位管理"}, button = "启用/禁用")
    @OperationLog(detail = "单位管理启用/禁用", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @GetMapping("/unitState")
    public Object unitState(@NotNull Integer id, @NotNull Integer state) {
        if (!ObjectUtils.allNotNull(id, state)) {
            return ResponseUtil.badArgument();
        }
        // if (state != EnumFile.CommonState.Normal && state != EnumFile.ExamineState.NotPassed) {
        //     return ResponseUtil.badArgumentValue();
        // }
        GeUnit geUnit = new GeUnit();
        geUnit.setId(id);
        geUnit.setState(state);
        int i = unitService.updateByIdState(geUnit);
        if (i == 0) {
            return ResponseUtil.updatedDataFailed();
        }
        return ResponseUtil.ok();
    }

    /**
     * 单位注册
     *
     * @param body { username : 用户名, unitname : 单位名称, ... }
     */
    @RequiresPermissions("admin:unit:register")
    @RequiresPermissionsDesc(menu = {"业务管理", "单位管理"}, button = "注册")
    @OperationLog(detail = "注册单位", operationType = OperationType.INSERT, userType = UserType.ADMIN)
    @PostMapping("/register")
    public Object register(@RequestBody String body) {
        GeUnit unit = JSON.parseObject(body, GeUnit.class);
        GeUser user = JSON.parseObject(body, GeUser.class);
        user.setRealname(unit.getLinkman());
        user.setTelephone(unit.getLinkphone());
        Object error = validate(unit, user);
        if (error != null) {
            return error;
        }
        // GeSystemparameter node_idcode = systemparameterService.selectByCode(EnumFile.SystemParameter.NODE_IDCODE);
        // if (node_idcode == null) {
        //     return ResponseUtil.fail(402, "本节点尚未激活，无法注册单位");
        // }

        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        user.setPassword(encoder.encode(user.getPassword()));
        unitService.add(unit, user);

        return ResponseUtil.ok();
    }

    /**
     * 参数校验
     *
     * @param unit 单位信息
     * @param user 账号信息
     */
    public Object validate(GeUnit unit, GeUser user) {
        if (!ObjectUtils.allNotNull(
                user.getUsername(), user.getPassword(),
                unit.getUnitName(), unit.getUnitCode(), unit.getUnitAddress(), unit.getProvinceCode(),
                unit.getCityCode(), unit.getAreaCode(), unit.getUnitType(), unit.getTradeId(),
                unit.getLicense(), unit.getEmail(), unit.getLinkphone()
        )) {
            return ResponseUtil.badArgument();
        }
        if (!RegexUtil.isUsername(user.getUsername())) {
            return ResponseUtil.fail(USER_INVALID_NAME, "用户名不符合规定（长度在6-20位“aA-zZ”、“0-9”、“_”、“汉字”组成，不能以“_”结尾）");
        }
        if (user.getPassword().length() < 6) {
            return ResponseUtil.fail(USER_INVALID_PASSWORD, "密码长度不能小于6");
        }

        List<GeUser> userList = userService.findByUsername(user.getUsername());
        if (userList.size() > 0) {
            return ResponseUtil.fail(USER_NAME_EXIST, "用户名已经存在");
        }

        List<GeUnit> unitList = unitService.findByUnitName(unit.getUnitName());
        if (unitList.size() > 0) {
            return ResponseUtil.fail(USER_NAME_EXIST, "单位名称已经存在");
        }
        return null;
    }

    //endregion

    //region 审核管理--节点审核

    @RequiresPermissions("admin:exam:nodeexamlist")
    @RequiresPermissionsDesc(menu = {"审核管理", "节点审核"}, button = "查询")
    @OperationLog(detail = "节点审核列表", operationType = OperationType.SELECT, userType = UserType.ADMIN)
    @GetMapping("/nodeExamlist")
    public Object nodeExamlist(
            @RequestParam(defaultValue = "") String area,
            @RequestParam(defaultValue = "-1") Integer nodeType,
            @RequestParam(defaultValue = "") String keywords,
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer limit) {
        GeUser currentAdminUser = getCurrentAdminUser();
        Set<String> byRoleId = permissionService.queryByRoleId(currentAdminUser.getRoleId());
        List<Integer> examState = new ArrayList<>();
        if(byRoleId.contains("*")) {
            examState.add(EnumFile.ExamineState.Wait);
            examState.add(EnumFile.ExamineState.One);
            examState.add(EnumFile.ExamineState.Two);
        }else {
            examState.add(-2);
            if(byRoleId.contains("admin:exam:nodexamine")) {
                examState.add(EnumFile.ExamineState.Wait);
            }
            if(byRoleId.contains("admin:exam:nodexamine2")) {
                examState.add(EnumFile.ExamineState.One);
            }
            if(byRoleId.contains("admin:exam:nodexamine3")) {
                examState.add(EnumFile.ExamineState.Two);
            }
        }

        // List<NodeVo> userList = nodeService.selectNodeList(area, keywords, page, limit);
        // List<NodeVo> nodeExamlist = nodeService.selectNodeExamlist(nodeType, examState, keywords, page, limit);
        List<NodeApplyVo> nodeExamlist = nodeService.selectNodeApplyExamList(area, keywords, examState, page, limit);
        return ResponseUtil.okList(nodeExamlist);
    }

    /**
     * 节点审核详情
     *
     * @param id 节点ID
     */
    @RequiresPermissions("admin:exam:nodeexamdetail")
    @RequiresPermissionsDesc(menu = {"审核管理", "节点审核"}, button = "详情")
    @OperationLog(detail = "节点审核详情", operationType = OperationType.SELECT, userType = UserType.ADMIN)
    @GetMapping("/nodeExamDetail")
    public Object nodeExamDetail(@NotNull Integer id) {
        // NodeVo nodeVo = nodeService.findNodeById(id);
        NodeApplyVo nodeApply = nodeService.findNodeApplyById(id);
        if (nodeApply == null) {
            return ResponseUtil.badArgumentValue();
        }
        return ResponseUtil.ok(nodeApply);
    }

    /**
     * 节点审核通过/不通过--一审
     *
     * @param id 节点ID
     */
    @RequiresPermissions("admin:exam:nodexamine")
    @RequiresPermissionsDesc(menu = {"审核管理", "节点审核"}, button = "一审")
    @OperationLog(detail = "节点审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @ExamineLog(detail = "节点审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @GetMapping("/nodeExamine")
    public Object nodeExamine(@NotNull Integer id, @NotNull Integer examState, String remark) {
        // if (!ObjectUtils.allNotNull(id, examState, remark)) {
        //     return ResponseUtil.badArgument();
        // }
        // if (examState != EnumFile.ExamineState.Passed && examState != EnumFile.ExamineState.NotPassed) {
        //     return ResponseUtil.badArgumentValue();
        // }
        // int i = nodeService.updateNodeById(id, examState, remark);
        // if (i == 0) {
        //     return ResponseUtil.updatedDataFailed();
        // }
        // return ResponseUtil.ok();
        if (!ObjectUtils.allNotNull(id, examState, remark)) {
            return ResponseUtil.badArgument();
        }
        if (examState != EnumFile.ExamineState.Passed && examState != EnumFile.ExamineState.NotPassed) {
            return ResponseUtil.badArgumentValue();
        }
        GeNodeApply geNodeApply = new GeNodeApply();
        geNodeApply.setId(id);
        if(examState==EnumFile.ExamineState.Passed) {
            geNodeApply.setState(EnumFile.ExamineState.One);
        }else {
            geNodeApply.setState(examState);
        }
        geNodeApply.setRemark(remark);
        NodeApplyVo nodeApply = nodeService.findNodeApplyById(id);
        List<GeNode> nodeByApplyId = nodeService.findNodeByApplyId(nodeApply.getId());
        if(nodeByApplyId != null && nodeByApplyId.size()>0) {
            nodeService.deleteByPrimaryKey(nodeByApplyId.get(0).getId());
        }
        if(geNodeApply.getState().equals(EnumFile.ExamineState.Passed)) {
            List<GeNode> nodeByNodeName = nodeService.findNodeByNodeName(nodeApply.getNodeName());
            if(nodeByNodeName != null && nodeByNodeName.size()>0) {
                return ResponseUtil.fail(AUTH_NODEIDCODE_EXIST, "节点名称已经存在");
            }
//            if (nodeService.findByNodeIdcode(nodeApply.getNodeIdcode()).size() > 0) {
//                return ResponseUtil.fail(AUTH_NODEIDCODE_EXIST, "节点编码已经存在");
//            }
        }
        int i = nodeService.nodeApplyExamine(geNodeApply, GYHLW_COMPANYINFO_REPORTING, EnumFile.ExamineState.One);
        if (i == 0) {
            return ResponseUtil.updatedDataFailed();
        }

        return ResponseUtil.ok();

    }

    /**
     * 节点审核通过/不通过--一审
     *
     * @param id 节点ID
     */
    @RequiresPermissions("admin:exam:nodexamine2")
    @RequiresPermissionsDesc(menu = {"审核管理", "节点审核"}, button = "二审")
    @OperationLog(detail = "节点审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @ExamineLog(detail = "节点审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @GetMapping("/nodeExamine2")
    public Object nodeExamine2(@NotNull Integer id, @NotNull Integer examState, String remark) {
        // if (!ObjectUtils.allNotNull(id, examState, remark)) {
        //     return ResponseUtil.badArgument();
        // }
        // if (examState != EnumFile.ExamineState.Passed && examState != EnumFile.ExamineState.NotPassed) {
        //     return ResponseUtil.badArgumentValue();
        // }
        // int i = nodeService.updateNodeById(id, examState, remark);
        // if (i == 0) {
        //     return ResponseUtil.updatedDataFailed();
        // }
        // return ResponseUtil.ok();
        if (!ObjectUtils.allNotNull(id, examState, remark)) {
            return ResponseUtil.badArgument();
        }
        if (examState != EnumFile.ExamineState.Passed && examState != EnumFile.ExamineState.NotPassed) {
            return ResponseUtil.badArgumentValue();
        }
        GeNodeApply geNodeApply = new GeNodeApply();
        geNodeApply.setId(id);
        if(examState==EnumFile.ExamineState.Passed) {
            geNodeApply.setState(EnumFile.ExamineState.Two);
        }else {
            geNodeApply.setState(examState);
        }
        geNodeApply.setRemark(remark);
        NodeApplyVo nodeApply = nodeService.findNodeApplyById(id);
        List<GeNode> nodeByApplyId = nodeService.findNodeByApplyId(nodeApply.getId());
        if(nodeByApplyId != null && nodeByApplyId.size()>0) {
            nodeService.deleteByPrimaryKey(nodeByApplyId.get(0).getId());
        }
        if(geNodeApply.getState().equals(EnumFile.ExamineState.Passed)) {
            List<GeNode> nodeByNodeName = nodeService.findNodeByNodeName(nodeApply.getNodeName());
            if(nodeByNodeName != null && nodeByNodeName.size()>0) {
                return ResponseUtil.fail(AUTH_NODEIDCODE_EXIST, "节点名称已经存在");
            }
//            if (nodeService.findByNodeIdcode(nodeApply.getNodeIdcode()).size() > 0) {
//                return ResponseUtil.fail(AUTH_NODEIDCODE_EXIST, "节点编码已经存在");
//            }
        }
        int i = nodeService.nodeApplyExamine(geNodeApply, GYHLW_COMPANYINFO_REPORTING, EnumFile.ExamineState.Two);
        if (i == 0) {
            return ResponseUtil.updatedDataFailed();
        }

        return ResponseUtil.ok();

    }

    /**
     * 节点审核通过/不通过--三审
     *
     * @param id 节点ID
     */
    @RequiresPermissions("admin:exam:nodexamine3")
    @RequiresPermissionsDesc(menu = {"审核管理", "节点审核"}, button = "三审")
    @OperationLog(detail = "节点审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @ExamineLog(detail = "节点审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @GetMapping("/nodeExamine3")
    public Object nodeExamine3(@NotNull Integer id, @NotNull Integer examState, String remark, @NotNull String nodeIdcode) {
        // if (!ObjectUtils.allNotNull(id, examState, remark)) {
        //     return ResponseUtil.badArgument();
        // }
        // if (examState != EnumFile.ExamineState.Passed && examState != EnumFile.ExamineState.NotPassed) {
        //     return ResponseUtil.badArgumentValue();
        // }
        // int i = nodeService.updateNodeById(id, examState, remark);
        // if (i == 0) {
        //     return ResponseUtil.updatedDataFailed();
        // }
        // return ResponseUtil.ok();
        if (!ObjectUtils.allNotNull(id, examState, remark)) {
            return ResponseUtil.badArgument();
        }
        if (examState != EnumFile.ExamineState.Passed && examState != EnumFile.ExamineState.NotPassed) {
            return ResponseUtil.badArgumentValue();
        }
        GeNodeApply geNodeApply = new GeNodeApply();
        geNodeApply.setId(id);
        geNodeApply.setState(examState);
        geNodeApply.setRemark(remark);
        NodeApplyVo nodeApply = nodeService.findNodeApplyById(id);
        List<GeNode> nodeByApplyId = nodeService.findNodeByApplyId(nodeApply.getId());
        if(nodeByApplyId != null && nodeByApplyId.size()>0) {
            nodeService.deleteByPrimaryKey(nodeByApplyId.get(0).getId());
        }
        if(geNodeApply.getState().equals(EnumFile.ExamineState.Passed)) {
            nodeApply.setNodeIdcode("MA.10001." + nodeIdcode);
            geNodeApply.setNodeIdcode(nodeApply.getNodeIdcode());
            List<GeNode> nodeByNodeName = nodeService.findNodeByNodeName(nodeApply.getNodeName());
            if(nodeByNodeName != null && nodeByNodeName.size()>0) {
                return ResponseUtil.fail(AUTH_NODEIDCODE_EXIST, "节点名称已经存在");
            }
            if (nodeService.findByNodeIdcode(nodeApply.getNodeIdcode()).size() > 0) {
                return ResponseUtil.fail(AUTH_NODEIDCODE_EXIST, "节点编码已经存在");
            }
        }

        System.out.println("GYHLW_COMPANYINFO_REPORTING=" + GYHLW_COMPANYINFO_REPORTING);
        int i = nodeService.nodeApplyExamine(geNodeApply, GYHLW_COMPANYINFO_REPORTING, EnumFile.ExamineState.Passed);
        if (i == 0) {
            return ResponseUtil.updatedDataFailed();
        }

        return ResponseUtil.ok();

    }

    //endregion

    //region 审核管理--接入审核

    @RequiresPermissions("admin:exam:authexamlist")
    @RequiresPermissionsDesc(menu = {"审核管理", "接入审核"}, button = "查询")
    @OperationLog(detail = "接入审核列表", operationType = OperationType.SELECT, userType = UserType.ADMIN)
    @GetMapping("/authExamlist")
    public Object authExamlist(
            @RequestParam(defaultValue = "") String area,
            // @RequestParam(defaultValue = "-2") Integer authExamineState,
            @RequestParam(defaultValue = "") String keywords,
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer limit) {

        GeUser currentAdminUser = getCurrentAdminUser();
        Set<String> byRoleId = permissionService.queryByRoleId(currentAdminUser.getRoleId());
        List<Integer> examState = new ArrayList<>();
        if(byRoleId.contains("*")) {
            examState.add(EnumFile.ExamineState.Wait);
            examState.add(EnumFile.ExamineState.One);
            examState.add(EnumFile.ExamineState.Two);
        }else {
            examState.add(-2);
            if(byRoleId.contains("admin:exam:authxamine")) {
                examState.add(EnumFile.ExamineState.Wait);
            }
            if(byRoleId.contains("admin:exam:authxamine2")) {
                examState.add(EnumFile.ExamineState.One);
            }
            if(byRoleId.contains("admin:exam:authxamine3")) {
                examState.add(EnumFile.ExamineState.Two);
            }
        }


        // List<NodeVo> userList = nodeService.selectNodeList(area, keywords, page, limit);
        List<NodeVo> nodeExamlist = nodeService.selectAuthExamStatelist(area, keywords, examState, page, limit);
        return ResponseUtil.okList(nodeExamlist);
    }

    /**
     * 接入审核详情
     *
     * @param id 节点ID
     */
    @RequiresPermissions("admin:exam:authexamdetail")
    @RequiresPermissionsDesc(menu = {"审核管理", "接入审核"}, button = "详情")
    @OperationLog(detail = "接入审核详情", operationType = OperationType.SELECT, userType = UserType.ADMIN)
    @GetMapping("/authExamDetail")
    public Object authExamDetail(@NotNull Integer id) {
        NodeVo nodeVo = nodeService.findAuthById(id);
        if (nodeVo == null) {
            return ResponseUtil.badArgumentValue();
        }
        return ResponseUtil.ok(nodeVo);
    }

    /**
     * 接入审核通过/不通过 --一审
     *
     * @param id 节点ID
     */
    @RequiresPermissions("admin:exam:authxamine")
    @RequiresPermissionsDesc(menu = {"审核管理", "接入审核"}, button = "一审")
    @OperationLog(detail = "接入审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @ExamineLog(detail = "接入审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @GetMapping("/authExamine")
    public Object authExamine(@NotNull Integer id, @NotNull Integer examState, String remark) {
        if (!ObjectUtils.allNotNull(id, examState, remark)) {
            return ResponseUtil.badArgument();
        }
        if (examState != EnumFile.ExamineState.Passed && examState != EnumFile.ExamineState.NotPassed) {
            return ResponseUtil.badArgumentValue();
        }
        if(examState==EnumFile.ExamineState.Passed) {
            examState = EnumFile.ExamineState.One;
        }
        int i = nodeService.updateAuthById(id, examState, remark);
        if (i == 0) {
            return ResponseUtil.updatedDataFailed();
        }
        return ResponseUtil.ok();
    }

    /**
     * 接入审核通过/不通过 --二审
     *
     * @param id 节点ID
     */
    @RequiresPermissions("admin:exam:authxamine2")
    @RequiresPermissionsDesc(menu = {"审核管理", "接入审核"}, button = "二审")
    @OperationLog(detail = "接入审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @ExamineLog(detail = "接入审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @GetMapping("/authExamine2")
    public Object authExamine2(@NotNull Integer id, @NotNull Integer examState, String remark) {
        if (!ObjectUtils.allNotNull(id, examState, remark)) {
            return ResponseUtil.badArgument();
        }
        if (examState != EnumFile.ExamineState.Passed && examState != EnumFile.ExamineState.NotPassed) {
            return ResponseUtil.badArgumentValue();
        }
        if(examState==EnumFile.ExamineState.Passed) {
            examState = EnumFile.ExamineState.Two;
        }
        int i = nodeService.updateAuthById(id, examState, remark);
        if (i == 0) {
            return ResponseUtil.updatedDataFailed();
        }
        return ResponseUtil.ok();
    }

    /**
     * 接入审核通过/不通过 --三审
     *
     * @param id 节点ID
     */
    @RequiresPermissions("admin:exam:authxamine3")
    @RequiresPermissionsDesc(menu = {"审核管理", "接入审核"}, button = "三审")
    @OperationLog(detail = "接入审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @ExamineLog(detail = "接入审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @GetMapping("/authExamine3")
    public Object authExamine3(@NotNull Integer id, @NotNull Integer examState, String remark) {
        if (!ObjectUtils.allNotNull(id, examState, remark)) {
            return ResponseUtil.badArgument();
        }
        if (examState != EnumFile.ExamineState.Passed && examState != EnumFile.ExamineState.NotPassed) {
            return ResponseUtil.badArgumentValue();
        }

        int i = nodeService.updateAuthById(id, examState, remark);
        if (i == 0) {
            return ResponseUtil.updatedDataFailed();
        }
        return ResponseUtil.ok();
    }

    //endregion

    //region 审核管理--单位审核

    @RequiresPermissions("admin:exam:unitexamlist")
    @RequiresPermissionsDesc(menu = {"审核管理", "单位审核"}, button = "查询")
    @OperationLog(detail = "单位审核列表", operationType = OperationType.SELECT, userType = UserType.ADMIN)
    @GetMapping("/unitExamList")
    public Object unitExamList( @RequestParam(defaultValue = "") String area,
                                @RequestParam(defaultValue = "") String keywords,
                                @RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "10") Integer limit) {
        GeUser currentAdminUser = getCurrentAdminUser();
        Set<String> byRoleId = permissionService.queryByRoleId(currentAdminUser.getRoleId());
        List<Integer> examState = new ArrayList<>();
        if(byRoleId.contains("*")) {
            examState.add(EnumFile.ExamineState.Wait);
            examState.add(EnumFile.ExamineState.One);
            examState.add(EnumFile.ExamineState.Two);
        }else {
            examState.add(-2);
            if(byRoleId.contains("admin:exam:unitexamexamine")) {
                examState.add(EnumFile.ExamineState.Wait);
            }
            if(byRoleId.contains("admin:exam:unitexamexamine2")) {
                examState.add(EnumFile.ExamineState.One);
            }
            if(byRoleId.contains("admin:exam:unitexamexamine3")) {
                examState.add(EnumFile.ExamineState.Two);
            }
        }
        List<UnitVo> unitVos = unitService.selectUnitExamStateList(area, keywords, examState, page, limit);
        return ResponseUtil.okList(unitVos);
    }

    /**
     * 单位审核详情
     *
     * @param id 节点ID
     */
    @RequiresPermissions("admin:exam:unitexamdetail")
    @RequiresPermissionsDesc(menu = {"审核管理", "单位审核"}, button = "详情")
    @OperationLog(detail = "单位审核详情", operationType = OperationType.SELECT, userType = UserType.ADMIN)
    @GetMapping("/unitExamDetail")
    public Object unitExamDetail(@NotNull Integer id) {
        // UnitVo unitVo = unitService.selectUnitById(id);
        UnitVo unitVo = unitService.selectUnitTempById(id);
        if (unitVo == null) {
            return ResponseUtil.badArgumentValue();
        }
        return ResponseUtil.ok(unitVo);
    }

    /**
     * 单位审核通过/不通过--一审
     *
     * @param id 节点ID
     */
    @RequiresPermissions("admin:exam:unitexamexamine")
    @RequiresPermissionsDesc(menu = {"审核管理", "单位审核"}, button = "一审")
    @OperationLog(detail = "单位审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @ExamineLog(detail = "单位审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @GetMapping("/unitExamExamine")
    public Object unitExamExamine(@NotNull Integer id, @NotNull Integer examState, String remark) {
        if (!ObjectUtils.allNotNull(id, examState, remark)) {
            return ResponseUtil.badArgument();
        }
        if (examState != EnumFile.ExamineState.Passed && examState != EnumFile.ExamineState.NotPassed) {
            return ResponseUtil.badArgumentValue();
        }
        GeUnit geUnit = new GeUnit();
        geUnit.setId(id);
        if(examState==EnumFile.ExamineState.Passed) {
            geUnit.setExamState(EnumFile.ExamineState.One);
        }else {
            geUnit.setExamState(examState);
        }
        geUnit.setRemark(remark);
        int i = unitService.examUnit(geUnit);
        if (i == 0) {
            return ResponseUtil.updatedDataFailed();
        }
        return ResponseUtil.ok();
    }

    /**
     * 单位审核通过/不通过--二审
     *
     * @param id 节点ID
     */
    @RequiresPermissions("admin:exam:unitexamexamine2")
    @RequiresPermissionsDesc(menu = {"审核管理", "单位审核"}, button = "二审")
    @OperationLog(detail = "单位审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @ExamineLog(detail = "单位审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @GetMapping("/unitExamExamine2")
    public Object unitExamExamine2(@NotNull Integer id, @NotNull Integer examState, String remark) {
        if (!ObjectUtils.allNotNull(id, examState, remark)) {
            return ResponseUtil.badArgument();
        }
        if (examState != EnumFile.ExamineState.Passed && examState != EnumFile.ExamineState.NotPassed) {
            return ResponseUtil.badArgumentValue();
        }
        GeUnit geUnit = new GeUnit();
        geUnit.setId(id);
        if(examState==EnumFile.ExamineState.Passed) {
            geUnit.setExamState(EnumFile.ExamineState.Two);
        }else {
            geUnit.setExamState(examState);
        }
        geUnit.setRemark(remark);
        int i = unitService.examUnit(geUnit);
        if (i == 0) {
            return ResponseUtil.updatedDataFailed();
        }
        return ResponseUtil.ok();
    }

    /**
     * 单位审核通过/不通过--三审
     *
     * @param id 节点ID
     */
    @RequiresPermissions("admin:exam:unitexamexamine3")
    @RequiresPermissionsDesc(menu = {"审核管理", "单位审核"}, button = "三审")
    @OperationLog(detail = "单位审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @ExamineLog(detail = "单位审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    @GetMapping("/unitExamExamine3")
    public Object unitExamExamine3(@NotNull Integer id, @NotNull Integer examState, String remark) {
        if (!ObjectUtils.allNotNull(id, examState, remark)) {
            return ResponseUtil.badArgument();
        }
        if (examState != EnumFile.ExamineState.Passed && examState != EnumFile.ExamineState.NotPassed) {
            return ResponseUtil.badArgumentValue();
        }
        GeUnit geUnit = new GeUnit();
        geUnit.setId(id);
        geUnit.setExamState(examState);
        geUnit.setRemark(remark);
        int i = unitService.examUnit(geUnit);
        if (i == 0) {
            return ResponseUtil.updatedDataFailed();
        }
        return ResponseUtil.ok();
    }

    //endregion

    //region 审核管理--申请审核(作废)

    // @RequiresPermissions("admin:exam:nodeapplylist")
    // @RequiresPermissionsDesc(menu = {"审核管理", "申请审核"}, button = "查询")
    // @OperationLog(detail = "节点申请审核列表", operationType = OperationType.SELECT, userType = UserType.ADMIN)
    // @GetMapping("/nodeApplyList")
    public Object nodeApplyList(
            // @RequestParam(defaultValue = "-1") Integer nodeType,
            @RequestParam(defaultValue = "") String area,
            @RequestParam(defaultValue = "") String keywords,
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer limit) {

        List<NodeApplyVo> nodeApplyVos = nodeService.selectNodeApplyList(area, keywords, page, limit);
        return ResponseUtil.okList(nodeApplyVos);
    }

    /**
     * 节点申请审核详情
     *
     * @param id 节点ID
     */
    // @RequiresPermissions("admin:exam:nodeapplydetail")
    // @RequiresPermissionsDesc(menu = {"审核管理", "申请审核"}, button = "详情")
    // @OperationLog(detail = "节点申请审核详情", operationType = OperationType.SELECT, userType = UserType.ADMIN)
    // @GetMapping("/nodeApplydetail")
    public Object nodeApplydetail(@NotNull Integer id) {
        NodeApplyVo nodeApply = nodeService.findNodeApplyById(id);
        if (nodeApply == null) {
            return ResponseUtil.badArgumentValue();
        }
        return ResponseUtil.ok(nodeApply);
    }

    /**
     * 节点申请审核通过/不通过
     *
     * @param id 节点ID
     */
    // @RequiresPermissions("admin:exam:nodeapplyexamine")
    // @RequiresPermissionsDesc(menu = {"审核管理", "申请审核"}, button = "审核通过/审核不通过")
    // @OperationLog(detail = "节点申请审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    // @ExamineLog(detail = "节点申请审核", operationType = OperationType.UPDATE, userType = UserType.ADMIN)
    // @GetMapping("/nodeApplyExamine")
//    public Object nodeApplyExamine(@NotNull Integer id, @NotNull Integer examState, String remark) {
//        if (!ObjectUtils.allNotNull(id, examState, remark)) {
//            return ResponseUtil.badArgument();
//        }
//        if (examState != EnumFile.ExamineState.Passed && examState != EnumFile.ExamineState.NotPassed) {
//            return ResponseUtil.badArgumentValue();
//        }
//        GeNodeApply geNodeApply = new GeNodeApply();
//        geNodeApply.setId(id);
//        geNodeApply.setState(examState);
//        geNodeApply.setRemark(remark);
//        int i = nodeService.nodeApplyExamine(geNodeApply, GYHLW_COMPANYINFO_REPORTING);
//        if (i == 0) {
//            return ResponseUtil.updatedDataFailed();
//        }
//        return ResponseUtil.ok();
//    }

    //endregion

}
